<?php

namespace app\admin\controller;

class VideoComment extends Base
{
    public function all()
    {
        $videoTitle = null;
        $where = [];
        if (input('?id')) {
            $videoTitle = model('VideoList')->where('id', input('id'))->value('title');
            $where = [
                'video_id' => input('id')
            ];
        }
        $videoComments = model('VideoComment')->where($where)->with('video,member')->order('create_time', 'desc')->paginate(10);
        $viewData = [
            'videoTitle' => $videoTitle,
            'videoComments' => $videoComments
        ];
        $this->assign($viewData);
        return view();
    }

    public function del()
    {
        $videoCommentInfo = model('VideoComment')->find(input('post.id'));
        $result = $videoCommentInfo->delete();
        if ($result) {
            $this->success('删除成功！', 'admin/videoComment/all');
        }else {
            $this->error('删除失败！');
        }
    }
}
